package alg20241126;

public class Text2 {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int n = timeSeries.length;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            if(i == n - 1 || timeSeries[i] + duration< timeSeries[i+1]){
                ret += duration;
            }else{
                ret += timeSeries[i+1] - timeSeries[i];
            }
        }
        return ret;
    }
}
